package com.dmj.sqldsl.wrapper;

import com.dmj.sqldsl.builder.UpdateBuilder;
import com.dmj.sqldsl.builder.UpdateWhereBuilder;
import com.dmj.sqldsl.builder.column.type.ColumnLambda;

public class UpdateWrapper<T> extends Wrapper<T> {

  private final UpdateBuilder<T> updateBuilder;

  public UpdateWrapper(Class<T> entityClass) {
    super(entityClass);
    this.updateBuilder = UpdateBuilder.on(getEntityClass());
  }

  public final <R> UpdateWrapper<T> set(ColumnLambda<T, R> lambda, R value) {
    updateBuilder.set(lambda, value);
    return this;
  }

  public UpdateWhereBuilder<T> toUpdateBuilder() {
    return updateBuilder.where(getConditionsBuilder());
  }

  @Override
  protected Wrapper<T> createNewWrapper() {
    return new UpdateWrapper<>(getEntityClass());
  }
}
